using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ComponentFactory.Krypton.Toolkit;
using System.Reflection;
using MySkins;

namespace Test
{
    public partial class Form1 : ComponentFactory.Krypton.Toolkit.KryptonForm
    {
        public Form1()
        {
            syncupBackColor();
            KryptonManager.GlobalPaletteChanged += new EventHandler((s, e) => syncupBackColor());
            //this.AllowFormChrome = !Utils.IsCompositionEnabled;
            this.AllowStatusStripMerge = false;

            InitializeComponent();
        }

        private void syncupBackColor()
        {
            this.BackColor = KryptonManager.CurrentGlobalPalette.GetBackColor1(PaletteBackStyle.PanelClient, PaletteState.Normal);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            skinsToolStripMenuItem.DropDownItems.Clear();

            //PaletteManager.PreloadPalettes();

            foreach (PaletteItem item in PaletteManager.Items)
            {
                ToolStripItem menuItem = skinsToolStripMenuItem.DropDownItems.Add(item.DisplayName, null, new EventHandler(setPalette));
                menuItem.Tag = item.Name;
            }

            setPalette( PaletteManager.Seven);
        }

        private void setPalette(object sender, EventArgs e)
        {
            ToolStripItem menuItem = sender as ToolStripItem;

            setPalette( PaletteManager.GetPalette(menuItem.Tag as string));
        }

        private void setPalette(IPalette palette)
        {
            kryptonManager.GlobalPalette = palette;

             this.Text = "PaletteTest";

            if (palette != null)
                this.Text += " - " + palette.ToString();                          
        }
    }
}